package com.mobi.cacti.common;

import com.mobi.cacti.R;

import android.app.Activity;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.TextView;
import android.widget.Toast;

public class MockArrayAdapter extends ArrayAdapter<String> {
	private static Context context;
	private final String[] items;	 
	private int layoutItem;

	static class ViewHolder {
		public TextView text;
	}

	public MockArrayAdapter(final Activity activity, final int textViewResourceId, final String[] objects,int mLayoutItem)
    {
        super(activity, textViewResourceId, objects);

        context = getContext();
        items = objects;
        layoutItem = mLayoutItem;
    }

	public View getView(int position, View convertView, ViewGroup parent) {
		View rowView = convertView;
		if (rowView == null) {
			LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
			rowView = inflater.inflate(layoutItem, null);
			ViewHolder viewHolder = new ViewHolder();
			//viewHolder.text = (TextView) rowView.findViewById(R.id.tvCurciutItem);
			rowView.setTag(viewHolder);
		}
		ViewHolder holder = (ViewHolder) rowView.getTag();
		//final dtCircuit info = items[position];
		//String s = info.CircuitID;
		//holder.text.setText(s);
		holder.text.setText(items[position]);
		return rowView;

	}
	
	public static void ToastMessage(final Activity activity, final String message)
    {
        activity.runOnUiThread(new Runnable() {

            @Override
            public void run()
            {
                Toast.makeText(activity, message, Toast.LENGTH_SHORT).show();
            }
        });
    }
}
